package com.job.yangshida.homework0707.oop1;

/**
 * @author 杨士达
 * @version 1.0
 * @since 2022-07-08 17:48:51
 */
public class TestStudent {
    public static void main(String[] args) {
        //static 静态 简单认为 一个类行使用时不创建对象
        //静态变量不需要对象就能调用,但是也可以用对象调用
        System.out.println(com.job.yangshida.homework0707.oop1.Student.count);
        com.job.yangshida.homework0707.oop1.Student stu1=new com.job.yangshida.homework0707.oop1.Student();
        //不建议用对象调用类变量,建议用类名调用
        System.out.println(stu1.count);
        com.job.yangshida.homework0707.oop1.Student stu2=new com.job.yangshida.homework0707.oop1.Student(1);
        com.job.yangshida.homework0707.oop1.Student stu3=new com.job.yangshida.homework0707.oop1.Student("jake");
        com.job.yangshida.homework0707.oop1.Student stu4=new com.job.yangshida.homework0707.oop1.Student(2, "?");
        System.out.println(stu1.count);
        System.out.println(stu4.count);
        System.out.println(com.job.yangshida.homework0707.oop1.Student.count);
        stu2.count=1111;
        System.out.println(com.job.yangshida.homework0707.oop1.Student.count);
        //类方法 静态方法 建议使用类名调用
        //静态一方面是所有对象共享的,另一方面是为了不用创建对象就能使用一些行为和属性,
        // 在一些工具包里都是用的static math
        stu1.sayHello();
        stu4.sayHello();
        com.job.yangshida.homework0707.oop1.Student.sayHello();
    }
}
